//
//  WRegisterViewController.m
//  xmpp即时通信
//
//  Created by student on 16/1/24.
//  Copyright © 2016年 123. All rights reserved.
//

#import "WRegisterViewController.h"
#import "AppDelegate.h"

@interface WRegisterViewController ()
@property (weak, nonatomic) IBOutlet UITextField *usernameTextField;
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;

@end

@implementation WRegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(back:)];
    
}

- (void)back:(UIBarButtonItem *)item
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)reigster:(UIButton *)sender
{
    AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
    appDelegate.name = self.usernameTextField.text;
    appDelegate.password = self.passwordTextField.text;
    [appDelegate connectToServer:^(BlockResultLoginType type) {
       
        switch (type) {
            case BlockResultLoginFail:
                NSLog(@"注册失败");
                break;
            case BlockResultLoginSuccess:
                NSLog(@"注册成功");
                break;
            default:
                NSLog(@"网络连接超时");
                break;
        }
    }];
}


@end
